﻿using System;
using System.Windows.Forms;

namespace Связь_с_БД
{
    public partial class FormOrderOnTransfer : Form
    {
        public FormOrderOnTransfer()
        {
            InitializeComponent();
            _strings = new string[13];
        }

        private readonly string[] _strings;
        private void Button1Click(object sender, EventArgs e)
        {
            _strings[0] = comboBox2.Text;
            _strings[1] = comboBox1.Text;
            _strings[2] = textBox3.Text;
            _strings[3] = textBox4.Text;
            _strings[4] = textBox5.Text;
            _strings[5] = textBox6.Text;
            _strings[6] = dateTimePicker1.Text;
            _strings[7] = textBox8.Text;
            _strings[8] = textBox9.Text;
            _strings[9] = dateTimePicker3.Text;
            _strings[10] = textBox11.Text;
            _strings[11] = dateTimePicker2.Text;
            _strings[12] = textBox13.Text;

            var form = Owner as FormMain;
            if (form == null) return;
            if (IsAllMandatoryField())
            {
                form.PrintOrderOnTransfer(_strings);
                Close();
            }
            else
                MessageBox.Show(@"Не все поля заполнены", @"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
        private void Button2Click(object sender, EventArgs e)
        {
            Close();
        }
        private bool IsAllMandatoryField()
        {
            if (comboBox1.Text == string.Empty ||
                comboBox2.Text == string.Empty ||
                textBox11.Text == string.Empty ||
                textBox13.Text == string.Empty ||
                textBox3.Text == string.Empty ||
                textBox4.Text == string.Empty ||
                textBox5.Text == string.Empty ||
                textBox6.Text == string.Empty ||
                textBox8.Text == string.Empty ||
                textBox9.Text == string.Empty)
                return false;
            return true;
        }
    }
}
